//590.N叉树的后序遍历
//https://leetcode.cn/problems/n-ary-tree-postorder-traversal/?envType=daily-question&envId=2024-02-19
class Solution {
    vector<int> ret;
public:
    vector<int> postorder(Node* root) {
        dfs(root);
        return ret;
    }

    void dfs(Node* root)
    {
        if(root == nullptr) return;
        for(Node* nd:root->children) dfs(nd);
        ret.push_back(root->val);
    }
};